<template>
  <div class="info">
    <h3 style="display: inline-block; margin-right: 68%">添加仓库成员</h3>

    <el-divider />
    <div class="message2">
      <strong> 仓库成员配额说明 </strong>
      <br />
      个人私有仓库最多支持 5
      人协作（如个人拥有多个私有仓库，所有协作人数总计不得超过 5 人）
    </div>

    <h4>权限</h4>
    <el-select v-model="power" placeholder="Select" style="margin-bottom: 20px">
      <el-option :value="1" label="管理员"></el-option>
      <el-option :value="2" label="开发者"></el-option>
      <el-option :value="3" label="查看者"></el-option>
    </el-select>
    <h4>用户</h4>
    <div>
      <el-input
        v-model="inputUser"
        placeholder="请输入用户名"
        style="width: 400px"
      />
    </div>

    <el-button @click="addTeammate" class="addButton">添加</el-button>
  </div>
</template>


<script>
import request from "@/utils/request";
import { ElMessage } from "element-plus";
export default {
  data() {
    return {
      power: 2,
      inputUser: "",
    };
  },
  methods: {
    addTeammate() {
      if (this.inputUser == "") {
        ElMessage("请输入用户");
      } else {
        request
          .get(
            `/house/addhousemember?username=${this.$route.params.username}&housename=${this.$route.params.housename}&newusername=${this.inputUser}&type=${this.power}`,
          )
          .then((res) => {
            console.log(res);
            if (res.code == 200) {
              ElMessage("添加成功");
            } else {
              ElMessage("用户不存在");
            }
          });
      }
    },
  },
};
</script>


<style>
.info {
  display: inline-block;
  position: absolute;
  margin-top: 3%;
  margin-left: 5%;
}
.message2 {
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Liberation Sans",
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Wenquanyi Micro Hei",
    "WenQuanYi Zen Hei", "ST Heiti", SimHei, SimSun, "WenQuanYi Zen Hei Sharp",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-align: left;
  box-sizing: inherit;
  position: relative;
  min-height: 1em;
  margin: 1em 0em;
  padding: 1em 1.5em;
  line-height: 1.4285em;
  transition: opacity 0.1s ease, color 0.1s ease, background 0.1s ease,
    box-shadow 0.1s ease, -webkit-box-shadow 0.1s ease;
  font-size: 1em;
  border-radius: 4px;
  border: 1px solid #e3e9ed;
  background: #fff;
  margin-top: 0em;
  background-color: #fff8db;
  color: #b58105;
  box-shadow: 0px 0px 0px 1px #b58105 inset, 0px 0px 0px 0px rgba(0, 0, 0, 0);
}
.addButton {
  cursor: pointer;
  box-shadow: 0px 0em 0px 0px rgba(39, 41, 43, 0.15) inset;
  color: #fff;
  background: #fe7300;
  padding-left: 12px;
  padding-right: 12px;
  margin-top: 20px;
}
</style>